package cn.lu.joke;

import android.content.Context;
import android.support.annotation.NonNull;

import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.LruResourceCache;
import com.bumptech.glide.module.AppGlideModule;

@GlideModule
public class MyGlideModel extends AppGlideModule{
    // 50M
    private final static int DISK_CACHE_SIZE = 50 << 20;
    private final static int memoryCacheSizeBytes = 20 << 20; // 20mb

    @Override
    public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
        // Default empty impl.
        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, DISK_CACHE_SIZE))
                .setMemoryCache(new LruResourceCache(memoryCacheSizeBytes));
    }
}
